import { createApp } from 'vue'
import router from './router/index.js'
import App from './App.vue'

import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'

// ① 引入createPinia方法从pinia
import { createPinia } from 'pinia'
// ② 拿到pinia实例
const pinia = createPinia()
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'
// 2 pinia使用数据持久化插件
pinia.use(piniaPluginPersistedstate)

import * as ElementPlusIconsVue from '@element-plus/icons-vue'
const app = createApp(App)
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component)
}

app.directive("scrollBottom", {
    updated(el) {
        // 这里的el即是绑定指令处的dom元素
        el.scrollTo({
            top: el.scrollHeight - el.clientHeight,
            behavior: "smooth"
        })
    }
})
app
    .use(ElementPlus)
    .use(router)
    .use(pinia)
    .mount('#app')